package com.lantosec.hmrp.modules.monitor.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lantosec.hmrp.core.kit.PageVO;
import com.lantosec.hmrp.core.kit.Result;
import com.lantosec.hmrp.core.mvc.BaseController;
import com.lantosec.hmrp.modules.monitor.entity.SupplierTotalEntity;
import com.lantosec.hmrp.modules.monitor.service.IMonitorSupplierService;
import com.lantosec.hmrp.modules.supplier.entity.HisDrugDir;
import com.lantosec.hmrp.modules.supplier.entity.SupplierAccessory;
import com.lantosec.hmrp.modules.supplier.entity.SupplierInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 患者满意度 控制器
 *
 * @author AutoCode
 * @since 2020-05-27
 */
@Api(value = "大屏供应商控制器", tags = "大屏供应商控制器 ")
@RestController
@RequestMapping("/monitor/supplier")
@Log4j2
public class MonitorSupplierController extends BaseController {
    @Autowired
    private IMonitorSupplierService service;

    @GetMapping("getSupplierDirTotal")
    @ApiOperation(value = "供应商物资供应目录汇总")
    public Result<List<SupplierTotalEntity>> getSupplierDirTotal() {
        List<SupplierTotalEntity> total = service.getSupplierDirTotal();
        return Result.ok(total);
    }

    @GetMapping("getSupplierDetails")
    @ApiOperation(value = "供应商产品明细")
    public Result<Page<SupplierTotalEntity>> getSupplierDetails(
            @ApiParam(value = "分页对象", required = true) PageVO<SupplierTotalEntity> page,
            @ApiParam(value = "供应商分类id") @RequestParam(name = "dictionariesId", required = false) String dictionariesId
    ) {
        Page<SupplierTotalEntity> details = service.getSupplierDetails(page,dictionariesId);
        return Result.ok(details);
    }

    @GetMapping("getSupplierTotal")
    @ApiOperation(value = "供应商分类汇总")
    public Result<List<SupplierTotalEntity>> getSupplierTotal() {
        List<SupplierTotalEntity> total = service.getSupplierTotal();
        return Result.ok(total);
    }

    @GetMapping("getSupplierName")
    @ApiOperation(value = "分类下供应商名称及准入时间")
    public Result<Page<SupplierTotalEntity>> getSupplierName(
            @ApiParam(value = "分页对象", required = true) PageVO<SupplierTotalEntity> page,
            @ApiParam(value = "供应商分类id") @RequestParam(name = "dictionariesId", required = false) String dictionariesId
    ) {
        Page<SupplierTotalEntity> name  = service.getSupplierName(page,dictionariesId);
        return Result.ok(name);
    }

    @GetMapping("getSupplierBaseInfo")
    @ApiOperation(value = "供应商基本信息")
    public Result<SupplierInfo> getSupplierBaseInfo(
            @ApiParam(value = "供应商id") @RequestParam(name = "supplierCode", required = false) String supplierCode
    ) {
        SupplierInfo baseInfo  = service.getSupplierBaseInfo(supplierCode);
        return Result.ok(baseInfo);
    }

    @GetMapping("getSupplierProductInfo")
    @ApiOperation(value = "供应商产品信息")
    public Result<Page<HisDrugDir>> getProductInfo(
            @ApiParam(value = "分页对象", required = true) PageVO<SupplierTotalEntity> page,
            @ApiParam(value = "供应商id") @RequestParam(name = "supplierCode") String supplierCode,
            @ApiParam(value = "是否为药品，0否，1是") @RequestParam(name = "drugFlag") Integer drugFlag
    ) {
        Page<HisDrugDir> productInfo  = service.getSupplierProductInfo(page,supplierCode,drugFlag);
        return Result.ok(productInfo);
    }

    @GetMapping("getSupplierQualificationInfo")
    @ApiOperation(value = "供应商资质信息")
    public Result<List<SupplierAccessory>> getSupplierQualificationInfo(
            @ApiParam(value = "供应商id") @RequestParam(name = "supplierCode", required = false) String supplierCode
    ) {
        List<SupplierAccessory> supplierAccessory  = service.getSupplierQualificationInfo(supplierCode);
        return Result.ok(supplierAccessory);
    }
}
